<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <title>Title</title>
  </head>
  <body>
  
  </body>
  
  <script>
    /**
     * Cookie：
     *  - Expires：设置Cookie过期时间
     *  - Max-Age：设置Cookie失效需要经过的时间，优先级比Expires高
     *  - Domain：设置Cookie可送达的主机名
     *  - Path：设置Cookie可发生的URL上下文
     *  - Secure：设置Cookie安全标记，被标记的Cookie只能通过HTTPS发送
     *  */
    const cookie = document.cookie;
    console.log(cookie) // hh=aa; satoken=54aee6f0-1134-4aae-9e8a-354fa57dc83a
    
    document.cookie = "hh=aa"
    console.log(document.cookie) // hh=aa; satoken=54aee6f0-1134-4aae-9e8a-354fa57dc83a
    
    /**
     * localStorage
     */
    // 设置
    localStorage.setItem("k1", "v1")
    localStorage.setItem("k2", "v2")
    localStorage.setItem("k3", "v3")
    
    // 获取
    console.log(localStorage.getItem("k1")) // v1
    console.log(localStorage.key(1)) // k1
    
    // 移除
    localStorage.removeItem('k1')
    console.log(localStorage.getItem("k1")) // null
    localStorage.clear()
    console.log(localStorage.getItem("k2")) // null
    console.log(localStorage.getItem("k3")) // null
  
  </script>
</html>